package com.lktx.sso.scope;

import cn.dev33.satoken.oauth2.data.model.AccessTokenModel;
import cn.dev33.satoken.oauth2.data.model.ClientTokenModel;
import cn.dev33.satoken.oauth2.scope.handler.SaOAuth2ScopeHandlerInterface;
import cn.hserver.core.ioc.annotation.Autowired;
import cn.hserver.core.ioc.annotation.Bean;
import com.lktx.sso.admin.entity.SsoOrganization;
import com.lktx.sso.admin.entity.SsoUser;
import com.lktx.sso.admin.mapper.SsoUserMapper;

import java.util.LinkedHashMap;
import java.util.Map;

@Bean
public class UserinfoScopeHandler implements SaOAuth2ScopeHandlerInterface {

    @Autowired
    private SsoUserMapper ssoUserMapper;

    @Override
    public String getHandlerScope() {
        return "userinfo";
    }

    @Override
    public void workAccessToken(AccessTokenModel at) {
        Map<String, Object> userInfo = ssoUserMapper.getLoginUserInfo(at.getLoginId().toString());
        at.extraData.putAll(userInfo);
    }

    @Override
    public void workClientToken(ClientTokenModel ct) {
    }

}